package com.tx.framework.system;

import java.io.Serializable;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ResultBody<T> implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6428921428536630925L;

	/**
	 * 响应代码
	 */
	private String code;

	/**
	 * 响应消息
	 */
	private String message;

	/**
	 * 响应结果
	 */
	private T result;

	public ResultBody() {
		super();
		this.code = StatusEnum.SUCCESS.getCode();
		this.message = StatusEnum.SUCCESS.getMessage();
	}

	public ResultBody(T result) {
		super();
		this.code = StatusEnum.SUCCESS.getCode();
		this.message = StatusEnum.SUCCESS.getMessage();
		this.result = result;
	}

	public ResultBody(StatusEnum statusEnum, String message) {
		super();
		this.code = statusEnum.getCode();
		this.message = message;
	}

	public static ResultBody<?> exception(String exceptionMessage) {
		return new ResultBody<>(StatusEnum.EXCEPTION, exceptionMessage);
	}
	
	public static ResultBody<?> noLogin(String exceptionMessage) {
		return new ResultBody<>(StatusEnum.NOLOGIN, exceptionMessage);
	}
}
